//JavaScript Framework 2.0 Code
try{
Type.registerNamespace('com.yonyou.ncmm_pac_pda.MMIssueController');
com.yonyou.ncmm_pac_pda.MMIssueController = function() {
    com.yonyou.ncmm_pac_pda.MMIssueController.initializeBase(this);
    this.initialize();
}
function com$yonyou$ncmm_pac_pda$MMIssueController$initialize(){
    //you can programing by $ctx API
    //get the context data through $ctx.get()
    //set the context data through $ctx.push(json)
    //set the field of the context through $ctx.put(fieldName, fieldValue)
    //get the parameter of the context through $ctx.param(parameterName)
    //Demo Code:
    //    var str = $ctx.getString();      //获取当前Context对应的字符串
    //    alert($ctx.getString())          //alert当前Context对应的字符串
    //    var json = $ctx.getJSONObject(); //获取当前Context，返回值为json
    //    json["x"] = "a";        //为当前json增加字段
    //    json["y"] = [];           //为当前json增加数组
    //    $ctx.push(json);            //设置context，并自动调用数据绑定
    //    
    //    put方法需手动调用databind()
    //    var x = $ctx.get("x");    //获取x字段值
    //    $ctx.put("x", "b");     //设置x字段值
    //    $ctx.put("x", "b");     //设置x字段值
    //    $ctx.databind();            //调用数据绑定才能将修改的字段绑定到控件上
    //    var p1 = $param.getString("p1");   //获取参数p2的值，返回一个字符串
    //    var p2 = $param.getJSONObject("p2");   //获取参数p3的值，返回一个JSON对象
    //    var p3 = $param.getJSONArray("p3");   //获取参数p1的值，返回一个数组
    
    //your initialize code below...
    
}
    
function com$yonyou$ncmm_pac_pda$MMIssueController$evaljs(js){
    eval(js)
}

function com$yonyou$ncmm_pac_pda$MMIssueController$scanner(sender, args){
$scanner.open({ bindfield : "textbox0", callback : "scannercallback()"});
}
function scannercallback()
{
 var json = $ctx.getString("textbox0");
// $alert("二维码扫描结果:" + json); 
 $id("textbox0").set("value",json);
}

function com$yonyou$ncmm_pac_pda$MMIssueController$loaddata(sender, args){


}

com.yonyou.ncmm_pac_pda.MMIssueController.currentQueryCondition=null;
function com$yonyou$ncmm_pac_pda$MMIssueController$button2_onclick(sender, args){
//查询本日备料计划
	com.yonyou.ncmm_pac_pda.MMIssueController.currentQueryCondition={
			"drequiredate_dateeq":NCMMPubUtil.getNowDate()
		};

//下载最新的VO数据
	NCMMDBUtil.loadNCBaseData(PickmHeadVO, PickmItemVO, NCMMHttpUtil.BILL, currentQueryCondition,function(data){
		if(data != null){
			$alert("after success");
			addNewData2Local(PickmHeadVO, PickmItemVO, data);
			var json={listIssuedata:data};
		    $ctx.push(json);
		}
		
	});
	//保存下载数据到本地库表
	//addNewData2Local(PickmHeadVO, PickmItemVO, data);

}
//保存数据到本地库表
//VOClassHead：主表vo
//VOClassBody：子表vo，单表时为空
//vos：插入数据
function addNewData2Local(VOClassHead, VOClassBody, vos){
	//获取VO数据记录数
	var vocount = NCMMDBUtil.getBillCount(vos);
	if(vocount > 0){
		//清除本地原有数据
		NCMMDBUtil.clearAllOldData(VOClassHead, VOClassBody);
		//更新VO到本地表
		vocount = NCMMDBUtil.addNewDatas(VOClassHead, VOClassBody, vos);
	}
	
	$alert("下载了【" + vocount +"】条数据。" );	
}


function com$yonyou$ncmm_pac_pda$MMIssueController$button3_onclick(sender, args){

}
function com$yonyou$ncmm_pac_pda$MMIssueController$button4_onclick(sender, args){

}
function com$yonyou$ncmm_pac_pda$MMIssueController$button5_onclick(sender, args){

}
function com$yonyou$ncmm_pac_pda$MMIssueController$button1_onclick(sender, args){

}
function com$yonyou$ncmm_pac_pda$MMIssueController$imagebutton1_onclick(sender, args){
//查询条件

}
com.yonyou.ncmm_pac_pda.MMIssueController.prototype = {
    imagebutton1_onclick : com$yonyou$ncmm_pac_pda$MMIssueController$imagebutton1_onclick,
    button1_onclick : com$yonyou$ncmm_pac_pda$MMIssueController$button1_onclick,
    button5_onclick : com$yonyou$ncmm_pac_pda$MMIssueController$button5_onclick,
    button4_onclick : com$yonyou$ncmm_pac_pda$MMIssueController$button4_onclick,
    button3_onclick : com$yonyou$ncmm_pac_pda$MMIssueController$button3_onclick,
    button2_onclick : com$yonyou$ncmm_pac_pda$MMIssueController$button2_onclick,
    loaddata : com$yonyou$ncmm_pac_pda$MMIssueController$loaddata,
    scanner : com$yonyou$ncmm_pac_pda$MMIssueController$scanner,  
    initialize : com$yonyou$ncmm_pac_pda$MMIssueController$initialize,
    evaljs : com$yonyou$ncmm_pac_pda$MMIssueController$evaljs,
  
};
com.yonyou.ncmm_pac_pda.MMIssueController.registerClass('com.yonyou.ncmm_pac_pda.MMIssueController',UMP.UI.Mvc.Controller);
}catch(e){$e(e);}
